package mfuny.ggongal.admin.http;
import java.util.List;

import mfuny.ggongal.admin.Server;
import mfuny.ggongal.admin.json.JsonCreater;

import org.json.simple.JSONObject;

import com.ibatis.sqlmap.client.SqlMapClient;

public class HttpFaq {
	SqlMapClient sqlMapper;
	JsonCreater jc;
	
	public HttpFaq() throws Exception {
		sqlMapper = Server.getSqlMapper();
		jc = new JsonCreater();
	}
	
	//Faq 데이터 중 content를 제외한 모든 데이터를 JSON으로 가져옴.
	@SuppressWarnings("unchecked")
	public JSONObject faq_getDataForApp() throws Exception {
		List<Object> faq = sqlMapper.queryForList("faq_select_for_app", null);
		JSONObject json = jc.getJsonByMapList(faq, "faq");
		if( faq.size() > 0 ) {
			json.put("responseCode", 1);
		} else {
			json.put("responseCode", 0);
		}
		return json;
	}
	//특정번호의 Faq 본문 내용 주기.
    public String faq_getContentByNo(int faq_no) throws Exception {
        return (String)sqlMapper.queryForObject("faq_select_content", faq_no);
    }	
}
